<template>
  <view>
    <view>
      <u-tabbar
        :value="value4"
        @change="change5"
        :fixed="true"
        :placeholder="true"
        activeColor="#d81e06"
        :safeAreaInsetBottom="true">
        <u-tabbar-item
          :text="item.text"
          v-for="(item, index) in selectlist"
          :key="index">
          <template #active-icon>
            <image
              class="u-page__item__slot-icon"
              :src="item.selectedIconPath"></image>
          </template>
          <template #inactive-icon>
            <image class="u-page__item__slot-icon" :src="item.iconPath"></image>
          </template>
        </u-tabbar-item>
      </u-tabbar>
    </view>
  </view>
</template>
<script setup>
import { UseTypestore } from '@/stores/index'
const store = UseTypestore()
const value4 = computed(() => {
  return store.type
})
const selectlist = ref([])
// 骑手tabbar
const list = ref([
  {
    pagePath: '/pages/qishouindex/index',
    text: '首页',
    iconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/f9fcbf36-70c3-46b0-a036-f17e7965da22.png',
    selectedIconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/317f383b-3da1-486f-afef-c5e656de9062.png'
  },
  {
    pagePath: '/pages/order/history/index',
    text: '订单',
    iconPath: '../../static/tabbar/order.png',
    selectedIconPath: '../../static/tabbar/order1.png'
  },
  {
    pagePath: '/pages/mine/index',
    text: '我的',
    iconPath: '../../static/tabbar/nav3.png',
    selectedIconPath: '../../static/tabbar/nav3s.png'
  }
])
// 商家tabbar
const list2 = ref([
  {
    pagePath: '/pages/shangjiaindex/index',
    text: '首页',
    iconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/f9fcbf36-70c3-46b0-a036-f17e7965da22.png',
    selectedIconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/317f383b-3da1-486f-afef-c5e656de9062.png'
  },
  {
    pagePath: '/pages/food/index',
    text: '菜品',
    iconPath: '../../static/tabbar/nav2.png',
    selectedIconPath: '../../static/tabbar/nav2s.png'
  },
  {
    pagePath: '/pages/information/index',
    text: '数据',
    iconPath: '../../static/tabbar/msg1.png',
    selectedIconPath: '../../static/tabbar/msg.png'
  },
  {
    pagePath: '/pages/settings/index',
    text: '设置',
    iconPath: '../../static/tabbar/setting1.png',
    selectedIconPath: '../../static/tabbar/setting.png'
  }
])
// 站长tabbar
const list3 = ref([
  {
    pagePath: '/pages/zhanzhangindex/index',
    text: '首页',
    iconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/f9fcbf36-70c3-46b0-a036-f17e7965da22.png',
    selectedIconPath:
      'https://yong-shan-tuan.oss-cn-hangzhou.aliyuncs.com/317f383b-3da1-486f-afef-c5e656de9062.png'
  },
  {
    pagePath: '/pages/order/stationmaster/index',
    text: '订单',
    iconPath: '../../static/tabbar/order.png',
    selectedIconPath: '../../static/tabbar/order1.png'
  },
  {
    pagePath: '/pages/mine/index',
    text: '我的',
    iconPath: '../../static/tabbar/nav3.png',
    selectedIconPath: '../../static/tabbar/nav3s.png'
  }
])
const change5 = (url1) => {
  console.log(url1)
  store.setType(url1)
  uni.redirectTo({
    url: selectlist.value[url1].pagePath
  })
}
/**
 * @param 0就是骑手tabar，1-站长tabbar 2-商家tabar
 */

if (store.whichType == 0) {
  selectlist.value = list.value
} else if (store.whichType == 1) {
  selectlist.value = list3.value
} else {
  selectlist.value = list2.value
}
</script>
<style>
.u-page__item__slot-icon {
  width: 32rpx;
  height: 36rpx;
}
</style>
